package cn.cdeden.system.controller.system;

import cn.cdeden.common.core.domain.R;
import cn.cdeden.common.satoken.utils.LoginHelper;
import cn.cdeden.knowledge.api.domain.RemoteResourceTypeService;
import cn.cdeden.knowledge.api.domain.RemoteSchedulePermissionsService;
import cn.cdeden.knowledge.api.domain.vo.RemoteScheduleDetailsVo;
import cn.cdeden.knowledge.api.domain.vo.RemoteSchedulePermissionsVo;
import cn.cdeden.system.api.model.LoginUser;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * *作者：gjx
 * *日期：2024/7/10    11:40
 * *文件描述：
 */
@Validated
@RequiredArgsConstructor
@RestController
//@Api(tags = "日历权限管理")
@RequestMapping("/api/sys/schedule/permissions")
public class SysSchedulePermissionsController {

    @DubboReference
    private RemoteSchedulePermissionsService remoteSchedulePermissionsService;

    @GetMapping("/get-all")
//    @Log("查询权限")
//    @ApiOperation("查询权限")
    public R<List<RemoteSchedulePermissionsVo>> getAll() {
        return R.ok(remoteSchedulePermissionsService.getAll());
    }

    @PostMapping("/add")
//    @Log("新增权限")
//    @ApiOperation("新增权限")
    @Transactional
    public R add(@RequestBody RemoteSchedulePermissionsVo remoteSchedulePermissionsVo) {
        return R.ok(remoteSchedulePermissionsService.add(remoteSchedulePermissionsVo));
    }

    @GetMapping("/edit/{id}")
//    @Log("修改权限数据回显")
//    @ApiOperation("修改权限数据回显")
    public R<RemoteSchedulePermissionsVo> editQuery(@PathVariable Long id) {
        return R.ok(remoteSchedulePermissionsService.editQuery(id));
    }

    @PutMapping("/edit")
//    @Log("修改权限")
//    @ApiOperation("修改权限")
    @Transactional
    public R edit(@RequestBody RemoteSchedulePermissionsVo remoteSchedulePermissionsVo) {
        return R.ok(remoteSchedulePermissionsService.edit(remoteSchedulePermissionsVo));
    }

    @DeleteMapping("/delete/{id}")
    @Transactional
//    @Log("删除权限权限")
//    @ApiOperation("删除权限权限")
    public R delete(@PathVariable Long id) {
        return R.ok(remoteSchedulePermissionsService.delete(id));
    }

    @GetMapping("/get-relevance")
//    @Log("查询详细权限")
//    @ApiOperation("查询详细权限")
    public R<List<RemoteScheduleDetailsVo>> getRelevance() {
        return R.ok(remoteSchedulePermissionsService.getRelevance());
    }
}
